															   /****** Object:  Stored Procedure [dbo].spPhieuNhapGet Script Date: 6/12/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spPhieuXuatGetForPrinting]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spPhieuXuatGetForPrinting]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		24/06/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spPhieuXuatGetForPrinting]
(
	@SoPX nvarchar(14)
)
WITH ENCRYPTION
AS

SET NOCOUNT ON

SELECT 
	*
FROM 
	[tbl_PhieuXuat]	Inner join tbl_ChiTietPhieuXuat ON [tbl_ChiTietPhieuXuat].SoPX= [tbl_PhieuXuat].SoPX
	INNER JOIN [tbl_LuuKho] ON [tbl_ChiTietPhieuXuat].MaLuuKho = [tbl_LuuKho].MaLuuKho
	INNER JOIN tbl_KhachHang ON [tbl_KhachHang].MaKH = [tbl_PhieuXuat].MaKH
	INNER JOIN tbl_KhoHang ON [tbl_KhoHang].MaKho = [tbl_PhieuXuat].Makho
	INNER JOIN tbl_SanPham ON [tbl_Sanpham].MaThuoc = [tbl_LuuKho].Mathuoc
	INNER JOIN tbl_DonViTinh ON [tbl_DonViTinh].MaDonVi = [tbl_SanPham].MaDonVi
WHERE
	[tbl_PhieuXuat].[SoPX] = @SoPX
	
Select * from tbl_congty
GO

--GRANT EXECUTE ON [dbo].[spPhieuNhapGet] TO [sa]
--GO